<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<style type="text/css">
body{
	font-size: 2px；
}
</style>
<script type="text/javascript" src="../scripts/boot.js"></script>



<title>My JSP 'index.jsp' starting page</title>


</head>
<body>    
     
    <form id="form1" method="post">
        <input name="id" class="mini-hidden" />
        <div style="padding-left:11px;padding-bottom:5px;">
            <table style="table-layout:fixed;">
            	<tr>
            		<td>测试名称：<input class="mini-textbox" name="testplan" required="true"  emptyText="请输入信息"/></td>
            		<td>线程组名称：<input class="mini-textbox" name="ThreadGroup" required="true"  emptyText="请输入信息"/></td>
            	</tr>
            	<tr>
            		<td>遇到错误后的措施：<input class="mini-combobox" name="sample_error" data="Genders" required="true"  emptyText="请输入信息"/></td>
            		<td>循环次数：<input class="mini-textbox" vtype="int" name="loop" required="true"  emptyText="请输入信息"/></td>
            	</tr>
            	<tr>
            		<td>线程组个数：<input class="mini-textbox" vtype="int" name="num_threads" required="true"  emptyText="请输入信息"/></td>
            		<td>HTTP采样器名称：<input class="mini-textbox" name="HTTPSamplerProxy" required="true"  emptyText="请输入信息"/></td>
            	</tr>
            	<tr>
            		<td>测试网站：<input class="mini-textbox" name="HTTPSampler_domain" required="true"  emptyText="请输入信息"/></td>
            		<td>端口号：<input class="mini-textbox" vtype="int" name="HTTPSampler_port" required="true" emptyText="请输入信息"/></td>
            	</tr>
            	<tr>
            		<td>网站路径：<input class="mini-textbox" name="HTTPSampler_path" required="true"  emptyText="请输入信息"/></td>
            		<td>方法：<input class="mini-combobox" name="HTTPSampler_method" data="Genders1" required="true" emptyText="请输入信息"/></td>
            	</tr>
           </table>
           </div>
        <div style="text-align:center;padding:10px;">               
            <a class="mini-button" onclick="onOk" style="width:60px;margin-right:20px;">保存</a>       
            <a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>       
        </div>        
    </form>
    <script type="text/javascript">
    	var Genders = [{"id":"Continue","text":"Continue"},
    	               {"id":"Start Next Thread Loop","text":"Start Next Thread Loop"},
    	               {"id":"Stop Thread","text":"Stop Thread"},
    	               {"id":"Stop Test","text":"Stop Test"},
    	               {"id":"Stop Test Now","text":"Stop Test Now"}];
    	var Genders1=[{"id":"GET","text":"GET"},
    	              {"id":"POST","text":"POST"}];
        mini.parse();

        var form = new mini.Form("form1");

        function SaveData() {
            var o = form.getData();            

            form.validate();
            if (form.isValid() == false) return;

            var json = mini.encode([o]);
            $.ajax({
                url: "<%=basePath %>/CreateJMXServlet",
				type: 'post',
                data: { data: json },
                cache: false,
                success: function (text) {
                    CloseWindow("save");
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                    CloseWindow();
                }
            });
        }



        function CloseWindow(action) {            
            if (action == "close" && form.isChanged()) {
                if (confirm("数据被修改了，是否先保存？")) {
                    return false;
                }
            }
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();            
        }
        function onOk(e) {
            SaveData();
        }
        function onCancel(e) {
            CloseWindow("cancel");
        }
        //////////////////////////////////
 


    </script>
</body>
</html>